#!/bin/bash
model=`lscpu  |grep 'Model name' |awk -F':' '{print $2}' |awk '$1=$1'`
cpuTotal=`lscpu  |grep 'Socket' |awk -F':' '{print $2}' |awk '$1=$1'`
cpuCorePerSocket=`lscpu  |grep 'Core(s) per socket' |awk -F':' '{print $2}' |awk '$1=$1'`
cpuCacheSize=`cat /proc/cpuinfo |grep 'cache size' |head -1 |awk -F':' '{print $2}'| awk '$1=$1'`
cpuSpeed=`lscpu |grep 'Model name' |awk -F'@' '{print $2}' |awk '$1=$1'`
sn=''
brand='intel'
`echo "$model" |grep 'AMD' >/dev/null`
if [ $? -eq 0 ];then
    brand='amd'
fi

for ((i=1;i<=cpuTotal;i++));do
    echo "category=cpu;model=${model};sn=;brand=${brand};core=${cpuCorePerSocket};physicalid=${i};slot=CPU${i};speed=${cpuSpeed};cache=${cpuCacheSize}"
done
